#ifndef __CacheSim__CacheSimulator__
#define __CacheSim__CacheSimulator__

#include <string>
#include <iostream>
#include "Parser.h"
#include "Cache.h"
#include "DirectMappedCache.h"
#include "FullyAssociativeCache.h"
#include "SetAssociativeCache.h"

class CacheSimulator
{
public:
	enum Associativity
	{
		DirectMapped = 0,
		FullyAssociative = 1,
		SetAssociative = 2
	};

	struct CacheProperties
	{
		unsigned size;
		unsigned cacheLineSize;
		Associativity associativity;
	};

	CacheSimulator(CacheProperties &instrCacheProp, CacheProperties &dataCacheProp, std::string fileName);
	~CacheSimulator();

	void read();

private:
	Cache *getCacheType(CacheProperties properties);
	void computeLine(Parser::TraceElement &element);

private:
	Parser parser;
	Cache *dataCache;
	Cache *instructionCache;
	unsigned instructionHitCounter;
	unsigned instructionMissCounter;
	unsigned dataHitCounter;
	unsigned dataMissCounter;
};

#endif